//
//  File.swift
//  Erlan
//
//  Created by jiayi zhao on 2017/9/20.
//  Copyright © 2017年 luoningjia. All rights reserved.
//




import Foundation

extension NSString{
    func split(splitStr: NSString) -> [NSString]{
        
        var lastStr = self
        
        var result: [NSString] = []
        
        for _ in 0..<self.length{
            
            let strRange = lastStr.range(of: splitStr as String)
            
            if strRange.length != 0{
                
                let subStr = lastStr.substring(to: strRange.location)
                
                result.append(subStr as NSString)
                
                lastStr = lastStr.substring(from: strRange.location + splitStr.length) as NSString
                
            }
                
            else{
                
                result.append(lastStr)
                
                return removeNullValue(str: result)
                
            }
            
        }
        
        return []
        
    }
    
    
    func removeNullValue(str: [NSString]) -> [NSString]{
        
        var result: [NSString] = []
        
        for i in 0..<str.count{
            
            if str[i] != ""{
                
                result.append(str[i])
                
            }
            
        }
        
        return result
        
    }
    
}
 
